package org.example.design.singleton;

/**
 * @Classname Singleton
 * @Description 懒汉双重加载单例
 * @Date 2020/11/3 9:57 上午
 * @Created by xiangjd
 */
public class Singleton {
    private static volatile Singleton singleton;
    private Singleton() {
    }

    public static synchronized Singleton getSingleton() {
        if (singleton == null) {
            synchronized (Singleton.class) {
                if (singleton == null) {
                    singleton = new Singleton();
                }
            }
        }
        return singleton;
    }
}
